package com.jyniubi.core.controller.api;


import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.jyniubi.base.exception.Assert;
import com.jyniubi.base.result.R;
import com.jyniubi.base.utils.JwtUtils;
import com.jyniubi.core.pojo.entity.Borrower;
import com.jyniubi.core.pojo.vo.BorrowerVo;
import com.jyniubi.core.service.BorrowerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 借款人 前端控制器
 * </p>
 *
 * @author jyzhang
 * @since 2024-04-27
 */
@Api(tags = "借款人信息审核")
@RestController
@RequestMapping("/api/core/borrower")
public class ApiBorrowerController {
    @Resource
    private BorrowerService borrowerService;
    @ApiOperation("查询借款人审核状态")
    @GetMapping("/auth/borrowerStatus")
    public R getBorrowerStatus(@RequestHeader(value = "token",required = false) String token){
        Long userId = JwtUtils.getUserId(token);
        Integer status = borrowerService.getBorrowerStatus(userId);
        return R.ok().data("status",status);
    }
    @ApiOperation("保存借款人认证信息")
    @PostMapping("/auth/saveBorrower")
    public R saveBorrower(@RequestBody BorrowerVo borrowerVo,
                          @RequestHeader(value = "token",required = false) String token){
        Long userId = JwtUtils.getUserId(token);
        borrowerService.saveBorrower(borrowerVo,userId);
        return R.ok();
    }
}

